import { Log } from '#Libs/logs/logger.js';
import User from '#Models/user.js'
import { Repository } from '#Repositorys/repository.js';

class UserRepository extends Repository {

    constructor() {
        super()
    }

    newQuery = async (connect = '') => {
        User.setConnect(connect)
        User.setOptions({ sequelize: await User.getDB() })
        User.initModel()
        return User
    }



    create = async (user) => {
        try {

            Log.info('user', User)
            return await User.create(user)

        } catch (error) {
            throw error
        }
    }

    findOne = async (...args) => {
        return await User.findOne(...args)
    }

    validatePwd = async (pwd, hash) => {
        return User.validatePwd(pwd, hash)
    }

    isDisable = async (userInfo) => {
        return await User.isDisable(userInfo)
    }
}

export default new UserRepository()